import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
//保存原来的push方法
const originPush = VueRouter.prototype.push
VueRouter.prototype.push= function(location,resolved,rejected){
    if(resolved === undefined && rejected===undefined){
        //强制改变this指向路由器
        return originPush.call(this,location,resolved,rejected).catch(() => {})
    }else{
        return originPush.call(this,location,resolved,rejected)
    }
}
const originReplace = VueRouter.prototype.replace
VueRouter.prototype.push= function(location,resolved,rejected){
    if(resolved === undefined && rejected===undefined){
        return originReplace.call(this,location,resolved,rejected).catch(() => {})
    }else{
        return originReplace.call(this,location,resolved,rejected)
    }
}
export default new VueRouter({
    //注册路由
    routes,
})